// ***************************************************************************
// XMLHttpRequest 객체 생성
// ***************************************************************************
function createRequest(){
    try{
        request = new XMLHttpRequest();
    }catch (trymicrosoft){
        try{
            request = new ActiveXObject("Msxml2.XMLHTTP");
        }catch (othermicrosoft){
            try{
                request = new ActiveXObject("Microsoft.XMLHTTP");
            }catch (failed){
                request = null;
            }
        }
    }
    if (request == null){
        alert("Request 객체 생성 실패!!");
    }
}

// ***************************************************************************
// Ajax Object 를 요청 한다.
// ***************************************************************************
function requestSand(url, data){
    createRequest();

    var url = url;
    var postData = data;

    url += "?dm=" + new Date().getTime();

    request.open("POST", url, true);
    request.onreadystatechange = requestResponse;
    request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
    request.send(data);
}

// ***************************************************************************
// Response 를 처리하는 Call back Method 이다.
// ***************************************************************************
function requestResponse(){
    if (request.readyState == 4){
        if(request.status == 200){
            var newData = request.responseText; //서버에게 받는 값

            setResponse(newData);
        }else{
            alert("처리중 예외 - 상태코드 request.status : " + request.status);
        }
    }
}

